package com.example.sharpshopdemo.controller;

import com.example.sharpshopdemo.entity.Dict;
import com.example.sharpshopdemo.entity.Result;
import com.example.sharpshopdemo.entity.Role;
import com.example.sharpshopdemo.service.DictService;
import com.example.sharpshopdemo.service.RoleService;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/dict")
@CrossOrigin
public class DictController {
    @Autowired
    private DictService service;
    @GetMapping("/list")
    public Result list(){
        return service.getAll();
    }

    @PostMapping("/add")
    @Operation(summary = "添加用户")
    public Dict insertData(Dict dict){
        return new Dict();
    }

    @PostMapping("/update")
    @Operation(summary = "更新数据")
    public Dict updateDate(Dict dict){
        return new Dict();
    }

    @PostMapping("/delete")
    @Operation(summary = "删除数据")
    public Dict deleteDate(Dict dict){
        return new Dict();
    }
    @Autowired
    private DictService dictService;

    // 模糊查询端点
    @GetMapping("/dicts/name-like")
    public Result<List<Dict>> findDictsByNameLike(@RequestParam String keyword) {
        return dictService.findDictsByNameLike(keyword);
    }
}
